home *** CD-ROM | disk | FTP | other *** search
/ Total Network Tools 2002 / NextStepPublishing-TotalNetworkTools2002-Win95.iso / Archive / Web Server / PHP.EXE / pear / PHPDoc / accessor / PhpdocWarningAccessor.php < prev   
Encoding:
PHP Script  |  2001-02-18  |  2.2 KB  |  93 lines

  1. <?php
  2. /**
  3. * Extracts the warnings from PHPDoc warnings_* files.
  4. * @version  $Id: PhpdocWarningAccessor.php,v 1.2 2001/02/18 15:03:05 uw Exp $
  5. */
  6. class PhpdocWarningAccessor extends PhpdocAccessor {
  7.  
  8.     /**
  9.     * If set to true all get_xy() functions will free their resources.
  10.     *
  11.     * @var      boolean
  12.     * @access   public
  13.     */
  14.     var $freeOnGet = true;    
  15.     
  16.     /**
  17.     * Array of warnings.
  18.     *
  19.     * @var      array
  20.     */
  21.     var $warnings = array();
  22.     
  23.     /**
  24.     * Flag used to detect if get_xy() was called.
  25.     *
  26.     * @var      boolean
  27.     */
  28.     var $flag_build = false;
  29.     
  30.     /**
  31.     * Returns a hash of warnings in of the given XML file.
  32.     *
  33.     * @param    string  XML file
  34.     * @return   array
  35.     * @access   public
  36.     * @see      $freeOnGet
  37.     */
  38.     function getWarnings($xmlfile) {
  39.         
  40.         $this->buildWarnings($xmlfile);
  41.         
  42.         if ($this->freeOnGet) {
  43.             
  44.             $data = $this->warnings; 
  45.             $this->warnings = array();
  46.             return $data;
  47.             
  48.         } else {
  49.             
  50.             return $this->warnings;
  51.             
  52.         }
  53.         
  54.     } // end func getWarnings
  55.     
  56.     /**
  57.     * Build the internal list of warnings.
  58.     *
  59.     * @param    string  XML file to load
  60.     */
  61.     function buildWarnings($xmlfile) {
  62.         
  63.         if ($this->flag_build)
  64.             return;
  65.             
  66.         $this->flag_build = true;
  67.         $this->warnings        = array();
  68.         $this->loadXMLFile($xmlfile);
  69.  
  70.         if(!isset($this->xml["warnings"][0]))
  71.             $this->xml["warnings"] = array( $this->xml["warnings"] );
  72.         
  73.         reset($this->xml["warnings"]);
  74.         while (list($k, $warnings) = each($this->xml["warnings"])) {
  75.         
  76.             $file = $warnings["file"];
  77.             if (!isset($warnings["warning"][0])) 
  78.                 $warnings["warning"] = array($warnings["warning"]);
  79.             $this->warnings[$file] = $warnings["warning"];
  80.                     
  81.         }
  82.  
  83.         $this->xml = "";
  84.         
  85.     } // end func buildWarnings
  86.     
  87.     function init() {
  88.         $this->flag_build = false;
  89.     } // end func init
  90.     
  91. } // end class PhpdocWarningAccess
  92. ?>